$def with (book)
<?xml version="1.0" encoding="utf-8"?>
<rdf:RDF
  xmlns:rdf='http://www.w3.org/1999/02/22-rdf-syntax-ns#'
  xmlns:rdfs='http://www.w3.org/2000/01/rdf-schema#'
  xmlns:ol="http://openlibrary.org/type/edition#"
  xmlns:owl='http://www.w3.org/2002/07/owl#'
  xmlns:bibo='http://purl.org/ontology/bibo/'
  xmlns:rdvocab='http://RDVocab.info/elements/'
  xmlns:rdrel='http://RDVocab.info/RDARelationshipsWEMI/'
  xmlns:dcterms='http://purl.org/dc/terms/'
  xmlns:dc='http://purl.org/dc/elements/1.1/'
  xmlns:dcam='http://purl.org/dc/dcam/'
  xmlns:foaf='http://xmlns.com/foaf/0.1/'
  xmlns:ov='http://open.vocab.org/terms/'
>
    $if book.subtitle:
        $ title = book.title + ": " + book.subtitle
    $else:
        $ title = book.title

    $if book.pagination:
        $ pages = book.pagination
    $else:
        $ pages = book.number_of_pages

    $ work = book.works and book.works[0]
    $if work:
        $ authors = work.get_authors()
    $else:
        $ authors = book.get_authors()

    $ contributors = book.get('contributors', [])

    $def display(tag, value):
        $if isinstance(value, list):
            $for x in value:
                <$tag>$x</$tag>
        $elif value:
            <$tag>$value</$tag>

    <rdf:Description rdf:about="http://openlibrary.org$book.key">
        $if work:
            <rdrel:workManifested rdf:resource="http://openlibrary.org$work.key"/>

        <!-- authors -->
        <bibo:authorList rdf:parseType="Collection">
        $for a in authors:
            <rdf:Description rdf:about="http://openlibrary.org$a.key">
                <foaf:name>$a.name</foaf:name>
            </rdf:Description>
        </bibo:authorList>
        $if contributors:
            <bibo:contributorList rdf:parseType="Collection">
            $for c in contributors:
                <foaf:Agent><foaf:name>$c.name</foaf:name></foaf:Agent>
            </bibo:contributorList>
        $:display("dcterms:contributor", book.contributions)
        <!-- bibliographic description -->
        $:display("dcterms:title", title)
        $:display("dcterms:publisher", book.publishers)
        $:display("rdvocab:placeOfPublication", book.publish_places)
        $:display("dcterms:issued", book.publish_date)
        $:display("dcterms:extent", pages)
        $:display("rdvocab:dimensions", book.physical_dimensions)
        $:display("bibo:edition", book.edition_name)
        <!-- subjects -->
        $:display("dc:subject", book.subjects)
      $for DDC in book.dewey_decimal_class:
        <dcterms:subject>
            <rdf:Description>
                <dcam:memberOf rdf:resource="http://purl.org/dc/terms/DDC"/>
                <rdf:value>$DDC</rdf:value>
            </rdf:Description>
        </dcterms:subject>
      $for LCC in book.lc_classifications:
        <dcterms:subject>
            <rdf:Description>
                <dcam:memberOf rdf:resource="http://purl.org/dc/terms/LCC"/>
                <rdf:value>$LCC</rdf:value>
            </rdf:Description>
        </dcterms:subject>
        <!-- description -->
        $:display("dcterms:description", book.description)
        $:display("rdvocab:note", book.notes)
        $for lang in book.languages:
            <dcterms:language>$lang.code</dcterms:language>
        <!-- identifiers -->
        $:display("dcterms:identifier", book.key)
        $:display("bibo:oclcnum", book.oclc_numbers)
        $:display("bibo:lccn", book.lccn)
        $:display("bibo:isbn10", book.isbn_10)
        $:display("bibo:isbn13", book.isbn_13)
    </rdf:Description>
    <!-- administrative -->
    <rdf:Description rdf:about="">
        <dcterms:modified rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">$book.last_modified.isoformat()</dcterms:modified>
        <dcterms:created rdf:datatype="http://www.w3.org/2001/XMLSchema#dateTime">$book.created.isoformat()</dcterms:created>
        <ov:versionnumber>$book.revision</ov:versionnumber>
    </rdf:Description>
</rdf:RDF>
